﻿namespace System;
/// <inheritdoc/>
public class NotSpecification<T> : Specification<T>
{
    #region Private Fields
    private readonly ISpecification<T> spec;
    #endregion
    #region Ctor

    /// <inheritdoc/>
    public NotSpecification(ISpecification<T> specification)
    {
        spec = specification;
    }
    #endregion
    #region Public Methods
    /// <inheritdoc/>
    public override Expression<Func<T, bool>> GetExpression()
    {
        var body = Expression.Not(spec.GetExpression().Body);
        return Expression.Lambda<Func<T, bool>>(body, spec.GetExpression().Parameters);
    }
    #endregion
}
